/*
 * gameobjectreader.h
 *
 *  Created on: Nov 19, 2009
 *      Author: magnus
 */

#ifndef GAMEOBJECTREADER_H_
#define GAMEOBJECTREADER_H_

#include <string>
#include <map>
#include "gameobjectfactory.h"

class TiXmlElement;

namespace spacedefender {


class SpaceshipInfo;
class MovableObject;
class GameObjectView;
typedef  const SpaceshipInfo* sip;

class GameObjectReader {
public:
	GameObjectReader();
	virtual ~GameObjectReader();

	Error_t Load(const std::string &fileName);
/**
 * Retrieves spaceship info for a given object id
 * @param id the spaceship to get
 * @return NULL if not found. Otherwise, spaceshipinfo returned.
 */

	 const SpaceshipInfo* GetSpaceShipInfo(const std::string& id) const;
	const GameObjectView* GetGameObjectView(const std::string& id) const;

private:

/***
 * Handles parsing of <movableobject> tags
 * @param moElement Non NULL pointer to element for <movableobject> tag
 * @param mo Non NULL pointer
 * @return
 */
	Error_t ParseMovableObject(TiXmlElement* moElement, MovableObject* mo);
	Error_t ParseView(TiXmlElement* wiElement, std::string& mesh);

	std::map<const std::string,sip> _spaceShipObjects;
	std::map<std::string,const GameObjectView*> _viewObjects;
};

}

#endif /* GAMEOBJECTREADER_H_ */
